package com.example.chunqiubackend.mapper;

import com.example.chunqiubackend.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;
import java.util.Date;

@Mapper
public interface UserMapper {
    /**
     * 根据邮箱查询用户（验证邮箱是否存在）
     * @param email
     * @return
     */
    @Select("select * from user where email =#{email}")
    User findByEmail(String email);

    /**
     * 注册用户
     * @param email
     * @param passwd
     */
    @Insert("insert into user(email,passwd,update_time,create_time) values (#{email},#{passwd},#{update_time},#{create_time})")
    void register(String email, String passwd, LocalDateTime update_time,LocalDateTime create_time);

    /**
     * 根据邮箱修改密码
     * @param email
     * @param new_passwd
     */
    @Update("update user set passwd =#{new_passwd},update_time=#{update_time} where email =#{email}")
    void uppasswd(String email,String new_passwd,LocalDateTime update_time);

    /**
     * 示例：使用XML的复杂动态查询
     * @param user
     * @return
     */
}
